#include "head.h"
/* Usage: */

bool my_rm(sendMsg msg, client_status user, int net_fd){
    if(strcmp(user.path_last, "")==0){
        printf("参数错误！\n");
        return 0;
    }

    size_t len = strlen(user.path_last);
    //若路径结尾有斜杠则删除斜杠
    if(user.path_last[len-1]=='/'&&len >1){
        user.path_last[len-1]='\0';
    }

    msg.mode = 5;
    msg.msg_len = strlen(user.path_last);

    msg.size = 1;
    strcpy(msg.msg, user.path_last);
    if(send(net_fd, &msg, sizeof(msg), 0)==-1){
        perror("send");
        return false;
    }
    recvMsg rbuf;
    int res_recv = recv(net_fd, &rbuf, sizeof(rbuf), 0);
    if(strcmp(rbuf.statu, "0")==0){
        printf("%s\n", rbuf.msg);
        return true;
    } else {
        printf("%s\n", rbuf.msg);
        return false;
    }
    return true;
}
